# -*- coding: utf-8 -*-
from models import StructureNode
from django.conf import settings

def current_node(request):
    current_root_node = current_top_node = current_node = StructureNode.objects.get_by_path(request.path)
    if current_node and current_node.get_ancestors().filter(level=1).count() > 0:
        current_root_node = current_node.get_ancestors().filter(level=1)[0]
    if current_node and current_node.get_ancestors().filter(level=2).count() > 0:
        current_top_node = current_node.get_ancestors().filter(level=2)[0]
    return {'current_node': current_node,
            'current_root_node': current_root_node,
            'current_top_node': current_top_node}

#EOF
